import request from './request'

// 获取敏感词列表
export function getSensitiveWordList(params) {
  return request({
    url: '/api/sensitive-words',
    method: 'get',
    params
  })
}

// 获取敏感词详情
export function getSensitiveWordDetail(id) {
  return request({
    url: `/api/sensitive-words/${id}`,
    method: 'get'
  })
}

// 创建敏感词
export function createSensitiveWord(data) {
  return request({
    url: '/api/sensitive-words',
    method: 'post',
    data
  })
}

// 更新敏感词
export function updateSensitiveWord(id, data) {
  return request({
    url: `/api/sensitive-words/${id}`,
    method: 'put',
    data
  })
}

// 删除敏感词
export function deleteSensitiveWord(id) {
  return request({
    url: `/api/sensitive-words/${id}`,
    method: 'delete'
  })
}

// 批量删除敏感词
export function batchDeleteSensitiveWords(ids) {
  return request({
    url: '/api/sensitive-words/batch-delete',
    method: 'post',
    data: { ids }
  })
}

// 导入敏感词
export function importSensitiveWords(file) {
  const formData = new FormData()
  formData.append('file', file)
  
  return request({
    url: '/api/sensitive-words/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 导出敏感词
export function exportSensitiveWords(params) {
  return request({
    url: '/api/sensitive-words/export',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

// 检查文本是否包含敏感词
export function checkSensitiveWords(text) {
  return request({
    url: '/api/sensitive-words/check',
    method: 'post',
    data: { text }
  })
}

// 获取敏感词分类列表
export function getSensitiveWordCategories() {
  return request({
    url: '/api/sensitive-words/categories',
    method: 'get'
  })
}

// 获取敏感词统计数据
export function getSensitiveWordStatistics() {
  return request({
    url: '/api/sensitive-words/statistics',
    method: 'get'
  })
}

// 获取敏感词使用记录
export function getSensitiveWordUsageRecords(params) {
  return request({
    url: '/api/sensitive-words/usage-records',
    method: 'get',
    params
  })
}